<?php

namespace App\Http\Controllers\Api;

use App\Model\National;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class NationalController extends BaseController
{
   protected $national_model;//国庆统计数据

    public function __construct()
    {
       $this->national_model = new National();
    }
    /**
     * 统计国庆送礼记录
     */
    public function getSendGiftLog()
    {
        //获取数据
        $res = $this->national_model->getGiftLog();
        if(!empty($res)){
            foreach($res as $k=>$v)
            {
                //获取商品信息
                $GoodsInfo = $this->national_model->getGiftInfo($v['gift_id']);
                if(!empty($GoodsInfo))
                {
                    $res[$k]['gift_name'] = $GoodsInfo['name'];
                    $res[$k]['price'] = $GoodsInfo['price'];
                }
            }
        }
        
        return $this->toJson(self::SUCCESS, $res);
    }

    /**
     * 送礼数据到达的阶层数
     */
    public function getSendGiftLevel(Request $request)
    {
        $type = $request->get('type',1);//1用户2主播3主播开播
        //获取数据
        $res = $this->national_model->getSendGiftLevel($type);
        return $this->toJson(self::SUCCESS, $res);
    }
}


